import request from 'utils/request'

// 轮播数据
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })
// 商品分类
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 商品列表
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
// 商品详情
const fetchItemDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 用户注册
const register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const doLogin = (params = {}) => request.post('/user/username/login', params)
// 读取购物车数据
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 修改购买数量
const setBuyNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 修改购物车商品选中状态
const switchCheck = (params = {}) => request.post('/shopping-cart/select', params)
const delCartItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 新增收货联系人
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 收货人列表
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 更新收货人信息
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)
// 获取收货人的详情
const fetchContactInfo = (params = {}) => request.get('/user/shipping-address/detail/v2', {
  params
})
// 更新收货人信息
const delContact = (params = {}) => request.post('/user/shipping-address/delete', params)
// 获取默认联系人
const fetchDefaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', {
  params
})
export {
  fetchHomeBanner,
  fetchCates,
  fetchItems,
  fetchItemDetail,
  register,
  doLogin,
  fetchCartItems,
  addCart,
  setBuyNumber,
  switchCheck,
  delCartItem,
  addContact,
  fetchContacts,
  updateContact,
  fetchContactInfo,
  delContact,
  fetchDefaultContact

}
